package com.two.screen.water.balance.adapter

import android.content.Context
import android.view.Gravity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.two.screen.water.balance.R
import com.two.screen.water.balance.bean.MenuBean
import com.two.screen.water.balance.utils.getColor
import q.rorbin.verticaltablayout.adapter.TabAdapter
import q.rorbin.verticaltablayout.widget.ITabView

class RightTabAdapter(var mContext: Context, fm: FragmentManager, var mMenus: MutableList<MenuBean>) : FragmentPagerAdapter(fm), TabAdapter {

    override fun getIcon(position: Int): ITabView.TabIcon = ITabView.TabIcon.Builder()
        .setIcon(mMenus[position].mSelectIcon, mMenus[position].mNormalIcon)
        .setIconGravity(Gravity.START)
        //.setIconMargin(CommUtils.dp2px(3))
        //.setIconSize(CommUtils.dp2px(60), CommUtils.dp2px(60))
        .setIconMargin(mContext.resources.getDimension(R.dimen.common_measure_5dp).toInt())
        .setIconSize(mContext.resources.getDimension(R.dimen.common_measure_40dp).toInt(), mContext.resources.getDimension(R.dimen.common_measure_40dp).toInt())
        .build()

    override fun getBadge(position: Int): ITabView.TabBadge? = null

    override fun getBackground(position: Int): Int = 0

    override fun getTitle(position: Int): ITabView.TabTitle = ITabView.TabTitle.Builder()
        .setContent(mMenus[position].mTitle)
        .setTextColor(getColor(R.color.f6), getColor(R.color.G567485))
        //.setTextSize(CommUtils.sp2px(15))
        .setTextSize(mContext.resources.getDimension(R.dimen.common_measure_15sp).toInt())

        .build()

    override fun getCount(): Int = mMenus.size

    override fun getItem(position: Int): Fragment = mMenus[position].mFragment

    override fun getPageTitle(position: Int): CharSequence? = mMenus[position].mTitle
}